import 'package:base_plugin/base_plugin.dart';
import 'package:dio/dio.dart';

class HttpCpfContributionService {
  static Future<Response> getCpfContributions() {
    return BaseConfig.httpBase.get('/api/cpf_contribution', {});
  }

  static Future<Response> getCpfContributionByYearMonth(
      {int year, String month}) {
    return BaseConfig.httpBase
        .get('/api/cpf_contribution/bydate?month=$month&year=$year', {});
  }

  static Future<Response> getCpfContributionID(int id) {
    return BaseConfig.httpBase.get('/api/cpf_contribution/$id', {});
  }

  static Future<Response> deleteCpfContribution(int invoice) {
    return BaseConfig.httpBase.deleteJson('/api/cpf_contribution/$invoice', {});
  }

  static Future<Response> createCpfContribution({
    String start_date,
    String end_date,
    String year,
    String month,
    int company_id,
    num employee_cpf,
    num employer_cpf,
    num cpf_overdue_interest,
    num fwl,
    num fwl_overdue_interest,
    num sdl,
    num community_donation,
    int community_donation_donors,
    num mbmf,
    int mbmf_donors,
    num sinda,
    int sinda_donors,
    num cdac,
    int cdac_donors,
    num ecf,
    int ecf_donors,
    String status,
    num total,
  }) {
    return BaseConfig.httpBase.postJson('/api/cpf_contribution', {
      "start_date": start_date,
      "end_date": end_date,
      "year": year,
      "month": month,
      "company_id": company_id,
      "employee_cpf": employee_cpf,
      "employer_cpf": employer_cpf,
      "cpf_overdue_interest": cpf_overdue_interest,
      "fwl": fwl,
      "fwl_overdue_interest": fwl_overdue_interest,
      "sdl": sdl,
      "community_donation": community_donation,
      "community_donation_donors": community_donation_donors,
      "mbmf": mbmf,
      "mbmf_donors": mbmf_donors,
      "sinda": sinda,
      "sinda_donors": sinda_donors,
      "cdac": cdac,
      "cdac_donors": cdac_donors,
      "ecf": ecf,
      "ecf_donors": ecf_donors,
      "status": status,
      "total": total,
    });
  }

  static Future<Response> updateCpfContribution(
    int id, {
    String start_date,
    String end_date,
    String year,
    String month,
    int company_id,
    num employee_cpf,
    num employer_cpf,
    num cpf_overdue_interest,
    num fwl,
    num fwl_overdue_interest,
    num sdl,
    num community_donation,
    int community_donation_donors,
    num mbmf,
    int mbmf_donors,
    num sinda,
    int sinda_donors,
    num cdac,
    int cdac_donors,
    num ecf,
    int ecf_donors,
    String status,
    num total,
  }) {
    return BaseConfig.httpBase.putJson('/api/cpf_contribution/$id', {
      "start_date": start_date,
      "end_date": end_date,
      "year": year,
      "month": month,
      "company_id": company_id,
      "employee_cpf": employee_cpf,
      "employer_cpf": employer_cpf,
      "cpf_overdue_interest": cpf_overdue_interest,
      "fwl": fwl,
      "fwl_overdue_interest": fwl_overdue_interest,
      "sdl": sdl,
      "community_donation": community_donation,
      "community_donation_donors": community_donation_donors,
      "mbmf": mbmf,
      "mbmf_donors": mbmf_donors,
      "sinda": sinda,
      "sinda_donors": sinda_donors,
      "cdac": cdac,
      "cdac_donors": cdac_donors,
      "ecf": ecf,
      "ecf_donors": ecf_donors,
      "status": status,
      "total": total,
    });
  }

  static Future<Response> payCpfContribution({
    int cpf_contribution_id,
    int payment_type_id,
    int account_id,
    String issued_at,
    String cheque_number,
    String notes,
    List attachment_ids,
  }) {
    return BaseConfig.httpBase.postJson('/api/cpf_contribution/pay', {
      "cpf_contribution_id": cpf_contribution_id,
      "payment_type_id": payment_type_id,
      "account_id": account_id,
      "issued_at": issued_at,
      "cheque_number": cheque_number,
      "notes": notes,
      'attachment_ids': attachment_ids ?? [],
    });
  }
}
